import 'package:bt_dsp_88/tool/assets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';

import '../../model/model.dart';
import 'output_item.dart';
import 'section.dart';

class OutputView extends SectionView {
  void Function(ChannelModel) onTap;
  void Function(ChannelModel) onLongPress;
  @override
  OutputView(
      {super.key,
      required super.title,
      required super.ch_list,
      required this.onTap,
      required this.onLongPress});

  @override
  State<OutputView> createState() => _OutputViewState();
}

class _OutputViewState extends SectionViewState<OutputView> {
  @override
  Widget buildHeader(BuildContext context) {
    return Container(color: Colors.transparent);
  }

  @override
  Widget buildContent(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    double w = (size.width - 20 * 3 - 20).toDouble() / 4.0;
    double s = GlobalConfig.scaleH.roundDouble(2) - 0.05;

    return SizedBox(
      height: w * 3 / 5.0 * 2 * s + 10,
      child: GridView.extent(

          ///交叉轴最大的尺寸
          maxCrossAxisExtent: w * 3 / 5.0 * s,
          crossAxisSpacing: 10.0,
          mainAxisSpacing: 20.0,
          childAspectRatio: 3 / 5.0 * s,
          scrollDirection: Axis.horizontal,
          physics: const NeverScrollableScrollPhysics(),
          children: (widget.ch_list).map(($0) {
            return OutputItem(
                ch: $0, onTap: widget.onTap, onLongPress: widget.onLongPress);
          }).toList()),
    );
  }
}
